﻿using AutoMapper;
using BestTrader.Cms.Models;
using BestTrader.Cms.RmmfSoftServices.Models;
using BestTrader.Cms.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BestTrader.Cms.UserCenter.Profiles
{
    public class MapperProfiles : Profile
    {
        public MapperProfiles()
        {
            CreateMap<SysItemsDetail, ItemsDetailModel>();

            #region ManagerRole
            CreateMap<ManagerRoleAddOrModifyModel, ManagerRole>();
            #endregion

            #region Manager
            CreateMap<Manager, ManagerListModel>();

            CreateMap<ManagerModifyBankCardModel,ManagerBankCard>();

            CreateMap<ManagerAddOrModifyModel, Manager>();

            CreateMap<ManagerAgentRegisterModel, Manager>();
            CreateMap<ManagerTerminalRegisterModel, Manager>();

            #region 风软
            // 代理注册转换为风软的实体处理类
            //      代理没有银行卡信息信息
            CreateMap<Manager, CustomerInput>()
                .ForMember(source => source.LoginName, desc => desc.MapFrom(s => s.UserName))
                //.ForMember(source => source.Password, desc => desc.MapFrom(s => s.Password))
                .ForMember(source => source.RealName, desc => desc.MapFrom(s => s.RealName))
                .ForMember(source => source.Telephone, desc => desc.NullSubstitute(""))
                .ForMember(source => source.Email, desc => desc.NullSubstitute(""))
                .ForMember(source => source.DefaultLanguage, desc => desc.NullSubstitute(0))
                .ForMember(source => source.CreateDate, desc => desc.NullSubstitute(DateTime.Now))
                .ForMember(source => source.IsLockedOut, desc => desc.NullSubstitute(false))
                .ForMember(source => source.LastLockoutDate, desc => desc.NullSubstitute(DateTime.Now))
                .ForMember(source => source.SecEmail, desc => desc.NullSubstitute(""))
                .ForMember(source => source.UserTypeID, desc => desc.NullSubstitute(1))
                .ForMember(source => source.First_Name, desc => desc.NullSubstitute(""))
                .ForMember(source => source.Last_Name, desc => desc.NullSubstitute(""))
                .ForMember(source => source.Postal_Code, desc => desc.NullSubstitute(""))
                .ForMember(source => source.Mobile_Phone, desc => desc.MapFrom(s => s.Mobile))
                .ForMember(source => source.Identity_Type, desc => desc.NullSubstitute(0))
                .ForMember(source => source.Identity_Number, desc => desc.MapFrom(s => s.CardId))
                .ForMember(source => source.Current_Trading_Status, desc => desc.NullSubstitute(1))
                .ForMember(source => source.Gender, desc => desc.NullSubstitute(2))
                .ForMember(source => source.Payee_Name, desc => desc.MapFrom(s => s.BankType))
                .ForMember(source => source.Bank_Account, desc => desc.MapFrom(s => s.BankCard))
                //.ForMember(source => source.RoleID, desc => desc.MapFrom(s => s.UserName))
                //.ForMember(source => source.FirmStructureID, desc => desc.MapFrom(s => s.UserName))
                .ForMember(source => source.Client_Type, desc => desc.NullSubstitute(0));

            // 直客注册转换为风软的实体处理类
            //      直客注册没用有用户名和密码
            CreateMap<ManagerTerminalRegisterModel, CustomerInput>()
                //.ForMember(source => source.LoginName, desc => desc.MapFrom(s => s.RealName))
                //.ForMember(source => source.Password, desc => desc.MapFrom(s => s.Password))
                //.ForMember(source => source.RealName, desc => desc.MapFrom(s => s.RealName))
                .ForMember(source => source.Telephone, desc => desc.NullSubstitute(""))
                //.ForMember(source => source.Email, desc => desc.MapFrom(s =>s.Email))
                .ForMember(source => source.DefaultLanguage, desc => desc.NullSubstitute(0))
                .ForMember(source => source.CreateDate, desc => desc.NullSubstitute(DateTime.Now))
                .ForMember(source => source.IsLockedOut, desc => desc.NullSubstitute(false))
                .ForMember(source => source.LastLockoutDate, desc => desc.NullSubstitute(DateTime.Now))
                .ForMember(source => source.SecEmail, desc => desc.NullSubstitute(""))
                .ForMember(source => source.UserTypeID, desc => desc.NullSubstitute(1))
                .ForMember(source => source.First_Name, desc => desc.NullSubstitute(""))
                .ForMember(source => source.Last_Name, desc => desc.NullSubstitute(""))
                .ForMember(source => source.Postal_Code, desc => desc.NullSubstitute(""))
                .ForMember(source => source.Mobile_Phone, desc => desc.MapFrom(s => s.Mobile))
                .ForMember(source => source.Identity_Type, desc => desc.NullSubstitute(0))
                .ForMember(source => source.Identity_Number, desc => desc.MapFrom(s => s.CardId))
                .ForMember(source => source.Current_Trading_Status, desc => desc.NullSubstitute(1))
                .ForMember(source => source.Gender, desc => desc.NullSubstitute(2))
                .ForMember(source => source.Payee_Name, desc => desc.MapFrom(s => s.BankType))
                .ForMember(source => source.Bank_Account, desc => desc.MapFrom(s => s.BankCard))
                //.ForMember(source => source.RoleID, desc => desc.MapFrom(s => s.UserName))
                //.ForMember(source => source.FirmStructureID, desc => desc.MapFrom(s => s.UserName))
                .ForMember(source => source.Client_Type, desc => desc.NullSubstitute(0));
            #endregion

            #endregion

            #region Menu
            CreateMap<MenuAddOrModifyModel, Menu>();

            #endregion

            #region TradeCommission

            CreateMap<TradeCommission, TradeCommissionListModel>();

            CreateMap<TradeCommissionAddOrModifyModel, TradeCommission>();

            #endregion

            #region ExchangeRate

            CreateMap<ExchangeRate, ExchangeRateListModel>();
            CreateMap<ExchangeRateAddOrModifyModel, ExchangeRate>();

            #endregion

            #region RebateExtract

            CreateMap<RebateExtract, RebateExtractListModel>();
            CreateMap<RebateExtractAddOrModifyModel, RebateExtract>();

            #endregion

            #region ServiceCharge

            CreateMap<ServiceCharge, ServiceChargeListModel>();

            #endregion

            #region UserCenter

            CreateMap<Manager, InCoinUserModel>();
            CreateMap<Manager, OutCoinUserModel>();

            CreateMap<OutCashModel, UCInOutCash>();
            CreateMap<InCashModel, UCInOutCash>();
            CreateMap<UCInOutCash, ConfirmInCashModel>();
            CreateMap<UCExchangeRateManagerModel, UCExchangeRateManager>();
            CreateMap<UCExchangeRateModel, UCExchangeRate>();
            
            CreateMap<QRCodeModel, UCAlipayInCash>()
                    .ForMember(dto => dto.QRCode, opt => opt.MapFrom(entity => entity.qrcode))
                    .ForMember(dto => dto.State, opt => opt.MapFrom(entity => entity.state))
                    .ForMember(dto => dto.Order, opt => opt.MapFrom(entity => entity.order))
                    .ForMember(dto => dto.Data, opt => opt.MapFrom(entity => entity.data))
                    .ForMember(dto => dto.Money, opt => opt.MapFrom(entity => entity.money))
                    .ForMember(dto => dto.Times, opt => opt.MapFrom(entity => entity.times))
                    .ForMember(dto => dto.OrderStatus, opt => opt.MapFrom(entity => entity.orderstatus))
                    .ForMember(dto => dto.Text, opt => opt.MapFrom(entity => entity.text));

            #endregion

            #region GomePay

            CreateMap<UCInOutCash, GomePayDFAddModel>()
                    .ForMember(dto => dto.ManagerId, opt => opt.MapFrom(entity => entity.UserManagerId))
                    .ForMember(dto => dto.UserName, opt => opt.MapFrom(entity => entity.UserName))
                    .ForMember(dto => dto.CustomerName, opt => opt.MapFrom(entity => entity.UserRealName))
                    .ForMember(dto => dto.Amount, opt => opt.MapFrom(entity => entity.RMBMoney))
                    .ForMember(dto => dto.IssueBankName, opt => opt.MapFrom(entity => entity.UserBankType))
                    .ForMember(dto => dto.AccountNumber, opt => opt.MapFrom(entity => entity.UserCardNo))
                    .ForMember(dto => dto.OrderNumber, opt => opt.MapFrom(entity => entity.OrderNo));


            CreateMap<GomePayDFAddModel, UCGomePayDF>();

            CreateMap<GomePayDFAddModel, GomePayDFModel>();


            CreateMap<GomePayDFBillQueryResultOutput, GomePayDFBillOutput>()
                    .ForMember(dto => dto.Amount, opt => opt.MapFrom(entity => entity.amount))
                    .ForMember(dto => dto.Currency, opt => opt.MapFrom(entity => entity.currency))
                    .ForMember(dto => dto.Code, opt => opt.MapFrom(entity => entity.op_ret_code))
                    .ForMember(dto => dto.Msg, opt => opt.MapFrom(entity => entity.op_err_msg))
                    .ForMember(dto => dto.OrderId, opt => opt.MapFrom(entity => entity.order_id))
                    .ForMember(dto => dto.OrderNumber, opt => opt.MapFrom(entity => entity.order_number))
                    .ForMember(dto => dto.Remark, opt => opt.MapFrom(entity => entity.remark))
                    .ForMember(dto => dto.DealTime, opt => opt.MapFrom(entity => entity.deal_time))
                    .ForMember(dto => dto.InOrderId, opt => opt.MapFrom(entity => entity.in_order_id));
            

            #endregion

            #region HistoryCash

            CreateMap<History_CashChanges, HistoryCashModel>();

            #endregion

        }
    }
}
